package com.pro.controller;

import com.pro.pojo.JsCourseClass;
import com.pro.pojo.JsSum;
import com.pro.pojo.JsonData;
import com.pro.service.JsCourseClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName:JsCourseClassController
 * Package:com.pro.controller
 * Description:
 *
 * @Date:2022/1/9 15:58
 * @Author: ZPT
 */
@RestController
@RequestMapping("/courseClass")
public class JsCourseClassController {

    @Autowired
    private JsCourseClassService courseClassService;

    /**
     *
     * @author ZPT
     * @date 2022/1/9 15:43
     * @content :课程分类数据
     */
    @RequestMapping("/getCourseClass")
    public JsonData getCourseClass(){
        List<JsCourseClass> courseClassList = courseClassService.getCourseClass();
        return courseClassList!=null?JsonData.buildSuccess(courseClassList):JsonData.buildError("服务端错误");
    }
    /**
     *
     * @author ZPT
     * @date 2022/1/9 15:43
     * @content :课程分类添加
     */
    @RequestMapping("/addCourseClass")
    public JsonData addCourseClass(JsCourseClass courseClass){
        Boolean aBoolean = courseClassService.addCourseClass(courseClass);
        return aBoolean!=null?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
    /**
     *
     * @author ZPT
     * @date 2022/1/9 15:43
     * @content :课程分类删除
     */
    @RequestMapping("/deleteCourseClass")
    public JsonData deleteCourseClass(Integer categroyId){
        Boolean aBoolean = courseClassService.deleteCourseClass(categroyId);
        return aBoolean!=null?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
    /**
     *
     * @author ZPT
     * @date 2022/1/9 15:43
     * @content :课程分类修改
     */
    @RequestMapping("/updateCourseClass")
    public JsonData updateCourseClass(JsCourseClass courseClass){
        Boolean aBoolean = courseClassService.updateCourseClass(courseClass);
        return aBoolean!=null?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
    /**
     *
     * @author ZPT
     * @date 2022/1/18 15:19
     * @content :课程分类点赞、分享、收藏、预览量
     */
    @RequestMapping("/getSum")
    public JsonData getSum(String field){
        List<JsSum> sumList = courseClassService.getSum(field);
        return sumList!=null?JsonData.buildSuccess(sumList):JsonData.buildError("服务端错误");
    }
}
